home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / smixc130.zip / SMIXC130.DOC < prev    next >
Text File  |  1997-06-06  |  13KB  |  243 lines

  1.          _____      __    __     ____     __   __       ______
  2.         /  _  \    |  \  /  |   |    |   |  \ /  |     /  __  \
  3.        |  / \__|   |   \/   |    |  |     \  ~  /     |  /  \__|
  4.        |  \___     |        |    |  |      |   |      | |
  5.         \___  \    |  /\/\  |    |  |      |   |      | |
  6.         __  \  |   |  |  |  |    |  |      |   |      | |     _
  7.        |  \_/  |   |  |  |  |    |  |     /  ^  \     |  \___/ |
  8.         \_____/    |__|  |__|   |____|   |__/ \__|     \______/
  9.  
  10.                          for Borland C real mode
  11.  
  12.                               Version 1.30
  13.                     Written by Ethan Brodsky (97/6/6)
  14.          Copyright 1995 by Ethan Brodsky.  All rights reserved.
  15.  
  16. This library is distributed AS IS.  The author specifically disclaims
  17. responsibility for any loss of profit or any consequential, incidental,
  18. or other damages.  SMIX is freeware and is distributed with full source
  19. code, which is copyright by Ethan Brodsky.  You are free to incorporate
  20. the code in full or part into your own programs as long as credit is
  21. given to Ethan Brodsky.  The source code may be distributed in its
  22. original form only, including this documentation and the copyright
  23. notices.
  24.  
  25. ------------------------------------------------------------------------
  26.  
  27. You may have used my SBVOX and SBDSP units.  They both played one VOC
  28. file at a time.  The whole VOC file had to be loaded into conventional
  29. memory, taking valuable memory from a real mode program.
  30.  
  31. SMIX will play up to 8 sounds at one time.  The sounds are stored in
  32. extended memory and copied to a small buffer as needed.  It should work
  33. with any Sound Blaster compatible sound card.  It uses auto-initialized
  34. DMA if it is supported, eliminating clicks between blocks.  If a SB16 is
  35. installed, it will use 16-bit sound output, increasing the sound
  36. quality.  Full Borland C source is included.
  37.  
  38. The sounds are stored on disk as raw signed 8-bit sample data, at a
  39. sampling rate of 22050 HZ, or the sampling rate specified in the SMIX
  40. source file.  There are two options for usage of XMS:
  41.   1)  Each sound can be stored in its own extended memory block.  This
  42.       allows random allocation and deallocation of sounds.  Each sound
  43.       uses an extended memory handle.  The default HIMEM configuration
  44.       has only 32 handles, so the maximum number of sounds that can be
  45.       loaded is 32.  (Less if TSRs or other drivers use handles)  This
  46.       is the default mode.
  47.   2)  All sounds can be loaded into one extended memory block.  Sounds
  48.       can be loaded one at a time, but all sounds must be deallocated
  49.       at once.  Initialize this mode by calling InitSharing before
  50.       allocating any sounds.  Sounds should be allocated and freed as
  51.       usual by using the LoadSound and FreeSound procedures, but all
  52.       extended memory will remain allocated until ShutdownSharing is
  53.       called.
  54.  
  55. In case you are wondering about the three counters displayed by the test
  56. program, the first one counts in the CPU's free time, the second counts
  57. the number of interrupts that have occurred, and the third is the number
  58. of sounds currently being played.  If you have any problems, please tell
  59. me what each counter is doing.
  60.  
  61. This library will work in the real-mode IDE but requires a little work
  62. to get it to work in the protected mode IDE.  By default, the IDE's DPMI
  63. extender uses all extended memory.  The demo requires 200k of extended
  64. memory, and any programs using SMIX require extended memory to hold all
  65. the sounds.  You can decrease the amount of extended memory used by the
  66. IDE by setting the DPMIMEM environment variable:
  67.   SET DPMIMEM=MAXMEM x
  68. where x is the number of kilobytes of extended memory to use for the
  69. IDE.  You will have to find a balance between memory left over for your
  70. program and memory available for IDE use.  (Source code, online help,
  71. compilation...)  It is very important to deallocate extended memory on
  72. program termination.  The run-time library will free the heap, but
  73. extended memory is left allocated.  The handles and memory will be lost
  74. until the next reboot.  It is not enough just to deallocate XMS at the
  75. end of your code, because a run-time error or exit() will stop execution
  76. before the memory has been deallocated.  I would recommend using an exit
  77. procedure, as demonstrated in the example program, to deallocate memory.
  78.  
  79. You can change the sampling rate used for output by changing the
  80. constant at the top of the SMIX source file.  If you decide to do this,
  81. all sound effects must be sampled at the rate you specify, or they will
  82. play at the wrong frequency.  Higher sampling rates will increase CPU
  83. usage.  Do not use a rate larger than 22050 HZ or SMIX will not work on
  84. sound cards older than the SB16.
  85.  
  86. SMIX either uses a raw 8-bit unsigned file format, or in a combined
  87. resource file.  I have included a program that will convert WAV files to
  88. the raw format necessary, and a program to combine raw sound files into
  89. a resource file.  The WAV files must be 8-bit and sampled at 22050 HZ,
  90. or the output will be distorted.  If you have changed the sampling rate
  91. constant in the SMIX source file then the sounds should be sampled at
  92. the rate you have specified.
  93.  
  94. Use the SNDLIB utility included with this package to build sound
  95. resource files.  The syntax for SNDLIB is similar to that of Borland's
  96. TLIB, but it is much more restrictive.  Remember that resources are
  97. identified by their "key", which comes after the filename when adding a
  98. resource.  The key is an 8 character case-insensitive string that is
  99. should be passsed to the load sound function after you have opened the
  100. resource file.
  101.  
  102. The mixing algorithm I use for the SB16 sacrifices volume level for
  103. precision.  This means that the mixed output will be fairly quiet on
  104. 16-bit sounds cards.  However, the SB16 has fairly load output, so it
  105. should come out about right.  If you think that the output is too quiet,
  106. you can disable 16-bit output by passing "0" as the 16-bit DMA channel
  107. to the SB initialization function, ignoring what the detect routine
  108. returns.
  109.  
  110. SMIX is not written in C++, but it can be used in a C++ program.
  111. However, you must compile the SMIX, XMS, and DETECT modules as C
  112. code, since they will not compile when treated as C++.  Since the SMIX
  113. modules are compiled as C code, function names are not mangled, and
  114. you must tell your program not to expect mangled names.  To do this,
  115. replace your SMIX includes with this code fragment:
  116.   extern "C"
  117.     {
  118.       #include "smix.h"
  119.       #include "detect.h"
  120.     }
  121.  
  122. I have several improvements planned, but I need feedback.  If you are
  123. using my code, I would greatly appreciate it if you would mail me and
  124. tell me about it.  If you have any bug reports, suggestions, or have
  125. made improvements, please tell me!  I have added volume control to the
  126. protected mode libraries, but not this version, since a 32k lookup table
  127. is required. If you want volume control implemented in this version,
  128. tell me!  I also have finished a FM synthesis MIDI music library and am
  129. working on a digital music library, so tell me what you want!
  130.  
  131. This library is freeware, but I would appreciate contributions so I can
  132. continue to buy development kits and upgrade my computer.  You don't
  133. NEED to send me anything, but if you are making money by using this,
  134. please send whatever you feel it is worth.
  135.  
  136. Features:
  137.   * Up to 8 sounds played simultaneously
  138.   * Sampling rate of 22050 HZ (changable at compile-time)
  139.   * Autoinitialized DMA prevents clicking
  140.   * 16-bit sound output increases quality
  141.   * Mixes in the background using a fraction of CPU time
  142.   * Sounds stored in extended memory
  143.   * Sound resource files allow you to store all sounds in one file
  144.  
  145. ------------------------------------------------------------------------
  146.  
  147. There are several ways to contact me:
  148.     E-Mail:  ebrodsky@pobox.com       (Preferred)
  149.              brodskye@cae.wisc.edu
  150.     WWW:     http://www.pobox.com/~ebrodsky/
  151.              http://www.xraylith.wisc.edu/~ebrodsky/
  152.     Phone:   (608) 238-4830
  153.     Mail:
  154.         Ethan Brodsky
  155.       4010 Cherokee Dr.
  156.       Madison, WI 53711
  157.  
  158. Bug fixes and other announcements will be posted in:
  159.     alt.sb.programmer
  160.     comp.archives.msdos.announce
  161.     comp.sys.ibm.pc.soundcard.tech
  162.     rec.games.programmer
  163. Up-to-date versions may be downloaded from:
  164.     http://www.pobox.com/~ebrodsky/smix/smix.html
  165.     ftp.simtel.net /pub/simtelnet/msdos/sound/smix*.zip
  166.     x2ftp.oulu.fi /pub/msdos/programming/mxlibs/smix*.zip
  167.  
  168. Revision history:
  169.  1.11 - Initial release corresponding with SMIX (Pascal) v1.11
  170.  1.15 - Switched to a new mixing algorithm that doesn't reduce sound
  171.         volume on 8-bit sound cards.  Fixed a problem with output on
  172.         Sound Blaster Pros.  Optimized mixing code.  Modified code in
  173.         exit procedure to reset sound card on termination.
  174.  1.16 - Fixed a file problem and modified shutdown code
  175.  1.17 - Fixed a problem that caused static in the last block of sound
  176.         loaded from an sound files with an odd length.  Thanks to Mike
  177.         Polly for informing me of this problem and helping me resolve
  178.         it.
  179.  1.18 - Fixed a detection problem with sound cards on DMA0.  Fixed the
  180.         failure condition in the reset_dsp procedure.  Added a new
  181.         sound_playing function to check if a sound is still playing.
  182.  1.19 - Fixed setup for SB16s that use an 8-bit DMA channel for 16-bit
  183.         sound.  Made all internal functions static.  Used far versions
  184.         of memset function so that SMIX will work in programs using
  185.         Borland C's large memory model.  Added sound_playing function
  186.         to smix.h and copied the interface documentation from smix.c to
  187.         smix.h.
  188.  1.20 - Fixed a bug in the XMS module that prevented it from working
  189.         in the huge model.  Fixed a bug that caused problems using the
  190.         sound_playing function to check for sounds using index 0.
  191.  1.21 - Added support for sound resource files.  New WAV2RAW converter
  192.         that correctly converts all conformant WAV files containing the
  193.         correct type of data.
  194.  1.22 - Fixed a problem in loading sounds from resource files that
  195.         caused a "burp" at the end of certain sound files.  Thanks to
  196.         Ron T. Lewis for his assistance in resolving this problem. Also
  197.         fixed a minor bug in the demo program.
  198.  1.25 - Put the MIXTEST.C demo back into the ZIP, since I forgot to
  199.         include it for the last release.  Fixed a problem in addressing
  200.         the second half of the DMA memory area.  Variable sampling rate.
  201.         Modified clipping data structures slightly.  Rewrote mixing code
  202.         in assembly for more efficiency.  Added FILE_ID.DIZ for BBS use.
  203.  1.26 - Fixed a minor bug in the 8-bit clipping routine, eliminating
  204.         clicking in 8-bit playback.
  205.  1.27 - Discovered a bug in the Borland C compiler.  When 386 code
  206.         generation is enabled, the compiler generates code that changes
  207.         the 32-bit registers, but doesn't preserve them for interrupt
  208.         handlers.  This caused problems with programs using SMIX and
  209.         certain TSRs (including SmartDrive, resulting in corruption of
  210.         disk I/O).  Fixed problem by disabling use of 386 instructions
  211.         for SMIX module.  Thanks to Thomas Wehrle for his assistance
  212.         in resolving this problem.  Also fixed minor bugs in WAV2RAW
  213.         and SNDLIB tools.
  214.  1.30 - Fixed a bug in the WAV2RAW converter that caused problems with
  215.         non-typical WAV files.  Changed interface variable dspversion
  216.         to type short.  Removed all floating point math from SMIX to
  217.         avoid linking in unnecssary floating point code.  Fixed a minor
  218.         bug in the initialization routines that prevented SMIX from
  219.         using autoinitialized DMA on sound cards with DSP v2.00.  Made
  220.         XMS move transfer parameter structures local variables.
  221.         Prevented SMIX from installing its exit handler multiple times.
  222.         Improved mixtest example program.  Changed load_sound to a
  223.         function and added error handling.  Made start_sound a function,
  224.         returning whether or not it could play the sound.  Removed
  225.         redundant function definition comments in smix.c.  If you want
  226.         to see an explanation of the functions, read smix.h.  Explicitly
  227.         disabled stack checking for SMIX modules to prevent erroneous
  228.         stack overflow errors if checking is enabled.  Switched calls
  229.         to min() and max() to my own MIN() and MAX() to avoid problems
  230.         if the macros are not implemented.  Removed redundant definition
  231.         of handler_installed.  Made open_sound_resource_file a function.
  232.         Changed getfreexms to return an unsigned short.  Added explicit
  233.         typecasts to eliminate warnings I previously had disabled.
  234.         Added instructions on how to use SMIX in a C++ program.  Thanks
  235.         to Ulrich Doewich, Pawel Veselov (a.k.a. Black Angel),Bojan
  236.         Resnik, Christopher Adams, and Robert Rand for their help in
  237.         improving SMIX.
  238.  
  239. I've been looking to get in with a commercial software company.  If any
  240. companies are interested, write to me at the above address.  Thanks!
  241.  
  242.     Ethan Brodsky
  243.